import request from '@/utils/request'

function getToken() {
  const token = localStorage.getItem('token')
  return token
}

//查询所有订单
export async function queryOpeOrderByCondition(params) {
  return request(`/hzsx/ope/order/queryOpeOrderByCondition`, {
    method: 'POST',
    data: params,
    headers: { token: getToken() }
  })
}

// 查询所有订单状态统计
export async function queryOrderGroupCountByCondition(params) {
  return request(`/hzsx/ope/order/queryOpeOrderGroupCountByCondition`, {
    method: 'POST',
    data: params,
    headers: { token: getToken() }
  })
}

// 查询所有订单带详情
export async function queryOrderByConditionExt(params) {
  return request(`/hzsx/ope/order/queryOpeOrderByConditionExt`, {
    method: 'POST',
    data: params,
    headers: { token: getToken() }
  })
}

//查询购买订单列表
export async function userOrderPurchase(params) {
  return request(`/hzsx/purchaseOrder/page`, {
    method: 'POST',
    data: params,
    headers: { token: getToken() }
  })
}

//查询关闭订单
export async function queryPendingOrderClosureList(params) {
  return request('/hzsx/ope/order/queryPendingOrderClosureList', {
    method: 'POST',
    data: params,
    headers: { token: getToken() }
  })
}

//关闭订单并退款
export async function closeUserOrderAndRefundPrice(params) {
  return request('/hzsx/ope/order/closeUserOrderAndRefundPrice', {
    method: 'POST',
    data: params,
    headers: { token: getToken() }
  })
}

// 获取各状态订单数量
export async function businessOrderStatisticsUsing(params) {
  return request('/hzsx/ope/order/opeOrderStatistics', {
    method: 'POST',
    body: params,
    headers: { token: getToken() }
  })
}

//查询逾期订单列表
export async function queryOpeOverDueOrdersByCondition(params) {
  return request('/hzsx/ope/order/queryOpeOverDueOrdersByCondition', {
    method: 'POST',
    data: params,
    headers: { token: getToken() }
  })
}

//查询即将到期订单列表
export async function queryOpeGoingOverDueOrdersByCondition(params) {
  return request('/hzsx/ope/order/queryOpeGoingOverDueOrdersByCondition', {
    method: 'POST',
    data: params,
    headers: { token: getToken() }
  })
}

// 查询未归还订单列表
export async function queryWaitingGiveBackOrder(params) {
  return request('/hzsx/ope/order/queryWaitingGiveBackOrder', {
    method: 'POST',
    data: params,
    headers: { token: getToken() }
  })
}

//查询电审订单
export async function queryTelephoneAuditOrder(params) {
  return request('/hzsx/ope/order/queryTelephoneAuditOrder', {
    method: 'POST',
    data: params,
    headers: { token: getToken() }
  })
}

//电审审核
export async function telephoneAuditOrder(params) {
  return request('/hzsx/ope/order/telephoneAuditOrder', {
    method: 'POST',
    data: params,
    headers: { token: getToken() }
  })
}

//查询运营买断订单
export async function queryOpeBuyOutOrdersByCondition(params) {
  return request('/hzsx/ope/order/queryOpeBuyOutOrdersByCondition', {
    method: 'POST',
    data: params,
    headers: { token: getToken() }
  })
}

//查询续租订单
export async function queryReletOrderByCondition(params) {
  return request('/hzsx/ope/order/queryReletOrderByCondition', {
    method: 'POST',
    data: params,
    headers: { token: getToken() }
  })
}

//获取上架渠道集合
export async function PlateformChannel(params) {
  return request('/hzsx/platform/selectPlateformChannel', {
    method: 'GET',
    data: params,
    headers: { token: getToken() }
  })
}

//获取顾客来源渠道集合
export async function SourceList(params) {
  return request('/hzsx/ope/order/getPlatformList', {
    method: 'GET',
    data: params,
    headers: { token: getToken() }
  })
}

//订单备注
export async function orderRemark(params) {
  return request('/hzsx/ope/order/orderRemark', {
    method: 'POST',
    data: params,
    headers: { token: getToken() }
  })
}

//查询订单详细
export async function queryOpeUserOrderDetail(params) {
  return request(`/hzsx/ope/order/queryOpeUserOrderDetail`, {
    method: 'POST',
    data: params,
    headers: { token: getToken() }
  })
}

//查询备注
export async function queryOrderRemark(params) {
  return request(`/hzsx/ope/order/queryOrderRemark`, {
    method: 'POST',
    data: params,
    headers: { token: getToken() }
  })
}

//查询物流信息
export async function queryExpressInfo(params) {
  return request(
    `/hzsx/ope/order/queryExpressInfo?expressNo=${params.expressNo}&receiverPhone=${params.receiverPhone}&shortName=${params.shortName}`,
    {
      method: 'GET',
      headers: { token: getToken() }
    }
  )
}

export async function expressInfo(params) {
  return request(`/hzsx/purchaseOrder/expressInfo?orderId=${params.orderId}`, {
    method: 'GET',
    headers: { token: getToken() }
  })
}

export async function contractReport(params) {
  return request(`/hzsx/ope/order/contractReport`, {
    method: 'POST',
    data: params,
    headers: { token: getToken() }
  })
}

//查询运营买断订单详情
export async function queryOpeBuyOutOrderDetail(params) {
  return request(`/hzsx/ope/order/queryOpeBuyOutOrderDetail`, {
    method: 'POST',
    data: params,
    headers: { token: getToken() }
  })
}

//查询续租订单详情
export async function queryUserReletOrderDetail(params) {
  return request(`/hzsx/ope/order/queryUserReletOrderDetail`, {
    method: 'POST',
    data: params,
    headers: { token: getToken() }
  })
}

//查询续租订单详情
export async function userOrdersPurchase(params) {
  return request(`/hzsx/purchaseOrder/detail?orderId=${params.orderId}`, {
    method: 'get',
    data: params,
    headers: { token: getToken() }
  })
}

export async function purchaseOrder(params) {
  return request('/hzsx/purchaseOrder/cancel', {
    method: 'POST',
    data: params,
    headers: { token: getToken() }
  })
}

//后台获取区域信息
export async function selectDistrict(params) {
  return request('/hzsx/district/selectDistrict', {
    method: 'GET',
    headers: { token: getToken() }
  })
}

//修改用户收货地址
export async function opeOrderAddressModify(params) {
  return request(`/hzsx/ope/order/opeOrderAddressModify`, {
    method: 'POST',
    data: params,
    headers: { token: getToken() }
  })
}

//订单导出
export async function exportOpeAllUserOrders(params) {
  return request(`/hzsx/ope/order/exportOpeAllUserOrders`, {
    method: 'POST',
    data: params,
    headers: { token: getToken() }
  })
}

export async function purchaseOrderExport(params) {
  return request(`/hzsx/purchaseOrder/export`, {
    method: 'POST',
    data: params,
    headers: { token: getToken() }
  })
}

export async function purchaseOrderDelivery(params) {
  return request(`/hzsx/purchaseOrder/delivery`, {
    method: 'POST',
    data: params,
    headers: { token: getToken() }
  })
}

//买断订单导出

export async function exportOpeBuyOutUserOrders(params) {
  return request(`/hzsx/ope/order/exportOpeBuyOutUserOrders`, {
    method: 'POST',
    data: params,
    headers: { token: getToken() }
  })
}

//逾期订单导出
export async function exportOpeOverDueUserOrders(params) {
  return request(`/hzsx/ope/order/exportOpeOverDueUserOrders`, {
    method: 'POST',
    data: params,
    headers: { token: getToken() }
  })
}

//续租订单导出
export async function exportReletOrders(params) {
  return request(`/hzsx/ope/order/exportReletOrders`, {
    method: 'POST',
    data: params,
    headers: { token: getToken() }
  })
}

//待归还订单导出
export async function exportWaitingGiveBack(params) {
  return request(`/hzsx/ope/order/exportWaitingGiveBack`, {
    method: 'POST',
    data: params,
    headers: { token: getToken() }
  })
}

//电审订单导出
export async function exportTelephoneAuditOrders(params) {
  return request(`/hzsx/ope/order/exportTelephoneAuditOrders`, {
    method: 'POST',
    data: params,
    headers: { token: getToken() }
  })
}

//订单关闭和退款导出
export async function exportCloseRefundOrders(params) {
  return request(`/hzsx/ope/order/exportCloseRefundOrders`, {
    method: 'POST',
    data: params,
    headers: { token: getToken() }
  })
}

export async function getSiriusReportRecord(params) {
  return request(`/hzsx/ope/order/querySiriusReportByUid`, {
    method: 'POST',
    data: params,
    headers: { token: getToken() }
  })
}

export async function getSiriusReportRecordV3(params) {
  return request(`/hzsx/ope/order/querySiriusReportByUidV3`, {
    method: 'POST',
    data: params,
    headers: { token: getToken() }
  })
}

export async function getSiriusReportRecordV4(params) {
  return request(`/hzsx/ope/order/queryRiskSuggestByOrderId`, {
    method: 'POST',
    data: params,
    headers: { token: getToken() }
  })
}

//查询订单账单相关信息
export async function queryOrderStagesDetail(params) {
  return request('/hzsx/ope/order/queryOrderStagesDetail', {
    method: 'POST',
    data: params,
    headers: { token: getToken() }
  })
}

// 查询蚂蚁链信息
export async function getChainInfoByOrderId(params) {
  return request(
    `/hzsx/ope/order/getChainInfoByOrderId?orderId=${params.orderId}`,
    {
      method: 'GET',
      headers: { token: getToken() }
    }
  )
}

// 查询蚁盾分
export async function getUserRisk(params) {
  return request(`/hzsx/ope/order/getUserRisk?orderId=${params.orderId}`, {
    method: 'GET',
    headers: { token: getToken() }
  })
}



// 退租
export async function quitLease(params) {
  return request('/hzsx/ope/order/quitLease4Order', {
    method: 'POST',
    data: params,
    headers: { token: getToken() }
  })
}

// 完结订单
export async function comleteOrder(params) {
  return request('/hzsx/ope/order/completed4Order', {
    method: 'POST',
    data: params,
    headers: { token: getToken() }
  })
}

// 关闭分期订单-线下履约
export async function closeStageOrder(params) {
  return request('/hzsx/ope/order/closeStageOrder', {
    method: 'POST',
    data: params,
    headers: { token: getToken() }
  })
}

// 碎屏险-线下履约
export async function closeBroken(params) {
  return request('/hzsx/ope/order/brokenInsuranceOfflinePayed', {
    method: 'POST',
    data: params,
    headers: { token: getToken() }
  })
}

// 逾期费-线下履约
export async function closeOverdue(params) {
  return request('/hzsx/ope/order/overdueFeeOfflinePayed', {
    method: 'POST',
    data: params,
    headers: { token: getToken() }
  })
}



import _request from '@/services/baseService'

export default {
  orderDelivery: data => {
    return _request(`/hzsx/ope/order/orderDelivery`, data)
  },
  merchantsIssuedStatements: data => {
    return _request(`/hzsx/ope/order/merchantsIssuedStatements`, data)
  },
  selectExpressList: data => {
    return _request(`/hzsxplatformExpress/selectExpressList`, data, 'get')
  },
  businessClosePayedOrder: data => {
    return _request(`/hzsx/ope/order/businessClosePayedOrder`, data)
  },
  queryOrderStatusTransfer: data => {
    return _request(`/hzsx/ope/order/queryOrderStatusTransfer`, data)
  },
  queryOrderAuditRecord: data => {
    return _request(`/hzsx/ope/order/queryOrderAuditRecord`, data)
  },
  telephoneAuditOrder: data => {
    return _request(`/hzsx/ope/order/telephoneAuditOrder`, data)
  },
  closeUserOrderAndRefundPrice: data => {
    return _request(`/hzsx/ope/order/closeUserOrderAndRefundPrice`, data)
  },
  queryOrderHasten: data => {
    return _request(`/hzsx/ope/order/queryOrderHasten`, data)
  },
  orderHasten: data => {
    return _request(`/hzsx/ope/order/orderHasten`, data)
  },
  getPreRiskCheck: params => {
    return request(`/hzsx/ope/order/userOrderBankPreRiskCheck?orderId=${params.orderId}`, {
      method: 'GET',
      headers: { token: getToken() }
    })
  },
  // 获取合同地址
  getSignDownloadUrl: params =>{
    return request(`//${location.hostname}/api-web/hzsx/api/order/esign/signFlowFileDownloadUrl?flowId=${params.flowId}`, {
      method: 'GET'
    })
  },
  // 银行资产结清通知
  assetCancelAgreeNotify: data =>{
    return _request(`/hzsx/ope/order/assetCancelAgreeNotify`, data)
  }
}
